<template>
  <div v-if="Object.keys(goods).length !==0" class="base-info" >
      <!-- //注意：涉及到三层对象数据调用时，第二层如果取不到，第三层会自动报错，
    这和vue渲染有关系，数据请求是异步的，所以开始数据时默认的空对象，
    解决方法：加v-if判断一下，注意不能用v-show,v-show是数据加载完毕后，决定是否显示 -->
    <div class="info-title">{{goods.itemInfo}}</div>
    <div class="info-price">
      <span class="new-price">{{goods.newPrice}}</span>
      <span class="old-price">{{goods.oldPrice}}</span>
      <span class="discount">{{goods.discount}}</span>
    </div>
  
    <div class="info-other">
      <span>{{goods.columns[0]}}</span>
      <span>{{goods.columns[1]}}</span>
      <span>{{goods.services[goods.services.length-1].name}}</span>
    </div>
    <div class="info-service">
      <span class="info-service-item" v-for="index in goods.services.length-1" :key="index">
        <img :src="goods.services[index-1].icon" alt="">
        <span>{{goods.services[index-1].name}}</span>
      </span>

    </div>
  </div>
</template>
<script>
export default {
  name:'DetailBasicMessage',
  props:{
    goods:{
      type:Object,
      default(){
        return {}
      }
    }
  }
}
</script>
<style scoped>
 .base-info {
    padding: 8px 6px 0;
    border-bottom: 3px solid #f2f5f8;
  }
  .info-title {
   text-align: justify;
   color: #222;
   font-size: 15px;
  }
  .info-price{
    margin-top: .266667rem;
  }
  .new-price {
    color: var(--color-high-text);
    font-size: 21px;
  }
  .old-price {
    font-size: 5px;
    margin-left: 5px;
    text-decoration: line-through;
    color: #999;
  }
  /* 折扣 */
  .discount {
    position: relative;
    top: -5px;
    margin-left: 5px;
    font-size: 12px;
    padding: .15rem .16rem;
    background-color: rgb(241, 62, 58);
    border-radius: 6px;
    color: white;
  }
  /* 其它模块 */
  .info-other {
    display: flex;
    justify-content: space-between;
    height: 35px;
    line-height: 35px;
    border-bottom: 1px solid #cccccc;
  }
  .info-other > span {
    font-size: 12px;
    color: #999;
  }
  /* 服务模块 */
  .info-service {
    display: flex;
    justify-content: space-between;
    font-size: 10px;
    height: 50px;
    line-height: 50px;
    color: #999;
  }
  .info-service img {
    width: 12px;
    position: relative;
    top: 1.5px;
  }
</style>